Emit list() for mvcombine so it runs on the analytics engine - #5663
Emit list() for mvcombine so it runs on the analytics engine#5663noCharger wants to merge 1 commit into
Conversation
PR Reviewer Guide 🔍(Review updated until commit d779cc2)Here are some key observations to aid the review process:
|
5007125 to
9c91c9b
Compare
|
Persistent review updated to latest commit 9c91c9b |
PR Code Suggestions ✨Latest suggestions up to d779cc2
Previous suggestionsSuggestions up to commit 9c91c9b
|
mvcombine lowered to Calcite ARRAY_AGG with an explicit IS NOT NULL filter. The analytics-engine (DataFusion) route cannot execute that shape: Calcite ARRAY_AGG infers a nullable-element ARRAY while the engine's array_agg operator infers a NOT NULL element, and the two cannot be reconciled during the aggregate rewrite. Switch performArrayAggAggregation to emit the existing PPL list() aggregate (PPLBuiltinOperators.LIST), which the analytics engine already supports. ListAggFunction drops null values internally, so the explicit IS NOT NULL filter is no longer needed. Behavior note: the combined field is now ARRAY<VARCHAR> (list() stringifies elements) and is capped at 100 values per group, matching list()'s documented contract. CalcitePPLMvCombineTest logical-plan and SparkSQL expectations updated for the LIST aggregate. Document the list()-based output (strings, 100-value cap, unordered) in mvcombine.md. Also update CalciteExplainIT explain_mvcombine.yaml fixtures (pushdown on/off) for the LIST plan (drop the IS NOT NULL projection; the identity EnumerableCalc is eliminated on the pushdown path). Signed-off-by: Louis Chu <lingzhichu.clz@gmail.com>
9c91c9b to
d779cc2
Compare
|
Persistent review updated to latest commit d779cc2 |
|
Closed in favor of a type-preserving fix on the analytics-engine (DataFusion) side. This PR emitted the PPL Instead, Verified live on the DataFusion route: |
Description
mvcombinelowered to CalciteARRAY_AGG(<field>) FILTER (<field> IS NOT NULL), which the analytics-engine (DataFusion) route cannot execute:ARRAY_AGGis not in the engine's aggregate function set, so the plan is rejected during marking. Mapping it into the engine is not viable either — CalciteARRAY_AGGinfers a nullable-elementARRAYwhile the engine'sarray_agginfers a NOT NULL element, and the two cannot be reconciled during the aggregate rewrite.The fix stays on the SQL side:
performArrayAggAggregationnow emits the existing PPLlist()aggregate (PPLBuiltinOperators.LIST), which the analytics engine already supports end to end (it maps to the engine'sarray_agg/list_mergeoperators).ListAggFunctionfilters nulls internally, so the explicitIS NOT NULLfilter is dropped. No analytics-engine (core) change is required.Behavior change (please review): the combined field is now
ARRAY<VARCHAR>—list()renders elements as strings and retains at most 100 values per group, per its documented contract. For string target fields (the documentedmvcombineuse) output is unchanged; numeric/other targets are now stringified and capped. On the Calcite/Lucene path this differs from the previous unbounded, type-preservingARRAY_AGG, so flagging in case reviewers prefer to gate it.Bug reproduce (analytics-engine / DataFusion route)
Composite/parquet index,
analytics.planner.prefer_metadata_driver=false(forces DataFusion):Before (
ARRAY_AGG) — rejected on the analytics engineLogical plan:
Physical plan: none — rejected during analytics-engine marking, before execution.
Output:
{ "error": { "reason": "There was internal problem at backend", "details": "No enum constant org.opensearch.analytics.spi.AggregateFunction.ARRAY_AGG", "type": "IllegalArgumentException" }, "status": 500 }After (
LIST) — runs on DataFusionLogical plan:
Physical plan (
profile=true; every nodeviableBackends=[[datafusion]], stagechosen_backend=datafusion):Output:
Related Issues
Related to #4766 ([FEATURE] Add
mvcombinecommand in PPL) — extends it to the analytics-engine (DataFusion) route.Check List
CalcitePPLMvCombineTestlogical-plan + Spark SQL expectations updated for theLISTaggregate.CalciteMvCombineCommandITis unchanged (it already asserts string-array output on a string field).docs/user/ppl/cmd/mvcombine.mdgains a Limitations note (string elements, 100-value cap, unordered).--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.